package com.tebiecloud.mpweixin.client.service;

import com.tebiecloud.common.model.ResultBody;
import com.tebiecloud.mpweixin.client.model.entity.MpweixinUser;
import com.tebiecloud.mpweixin.client.model.entity.MpweixinUserExpand;
import com.tebiecloud.mpweixin.client.model.entity.MpweixinUserWallet;
import com.tebiecloud.mpweixin.client.model.vo.DeductUserAmount;
import com.tebiecloud.mpweixin.client.model.vo.PlusUserAmountVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 用户接口
 */
public interface IMpweixinUserServiceClient {

    /**
     * 获取用户信息
     * @param userId
     * @return
     */
    @PostMapping("/feign/mpweixinuser/selectUserInfo")
    ResultBody<MpweixinUserExpand> selectUserInfo(@RequestParam("userId") long userId,
                                                  @RequestParam(value = "openid",required = false) String openid);

    /**
     * 获取公众号用户信息
     * @param openid
     * @return
     */
    @PostMapping("/feign/mpweixinuser/selectMpUserInfo")
    ResultBody<MpweixinUser> selectMpUserInfo(@RequestParam("openid") String openid);

    /**
     * 获取用户钱包
     * @param userId
     * @return
     */
    @PostMapping("/feign/mpweixinuser/selectUserWallet")
    ResultBody<MpweixinUserWallet> selectUserWallet(@RequestParam("userId") long userId);

    /**
     * 扣减用户钱包
     * @param userId 用户id
     * @param amount 余额
     * @param maxCoin 乖乖币
     * @return
     */
    @PostMapping("/feign/mpweixinuser/updateDeductAmount")
    ResultBody<DeductUserAmount> updateDeductAmount(@RequestParam("userId") long userId, @RequestParam("amount") int amount, @RequestParam("maxCoin") int maxCoin);

    /**
     * 添加用户钱包
     * @param userId 用户id
     * @param amount 余额
     * @param coin 乖乖币
     * @return
     */
    @PostMapping("/feign/mpweixinuser/updatePlusAmount")
    ResultBody<PlusUserAmountVo> updatePlusAmount(@RequestParam("userId") long userId, @RequestParam("amount") int amount, @RequestParam("coin") int coin);


    /**
     * 余额回滚
     * @param orderId 订单id
     * @param userId 用户id
     * @param amount 回滚金额
     * @param coin 回滚金币
     * @param type 回滚类型 5、订单关闭退返，6、退款退返
     * @return
     */
    @PostMapping("/feign/mpweixinuser/callBackPlusAmount")
    ResultBody<PlusUserAmountVo> callBackPlusAmount(
                    @RequestParam("orderId") long orderId,@RequestParam("userId") long userId,
                    @RequestParam("amount") int amount, @RequestParam("coin") int coin, @RequestParam("type") int type);

    /**
     * 新增余额明细
     * @param orderId
     * @param userId
     * @param amount
     * @param type
     * @return
     */
    @PostMapping("/feign/mpweixinuser/saveFlow")
    ResultBody<PlusUserAmountVo> saveFlow(
            @RequestParam("orderId") long orderId,@RequestParam("userId") long userId,
            @RequestParam("amount") int amount,@RequestParam("type") int type);

    /**
     * 新增乖乖比流水
     * @param orderId
     * @param userId
     * @param amount
     * @param type
     * @return
     */
    @PostMapping("/feign/mpweixinuser/saveCoinFlow")
    ResultBody<PlusUserAmountVo> saveCoinFlow(
            @RequestParam("orderId") long orderId,@RequestParam("userId") long userId,
            @RequestParam("amount") int amount,@RequestParam("type") int type);
}
